 <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>缓存配置工具</title>
    <!-- 新 Bootstrap 核心 CSS 文件  -->
    <link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-table.css">
    <link rel="stylesheet" type="text/css" href="../css/common.css">
    <link rel="stylesheet" type="text/css" href="../css/manage.css">
    <link rel="stylesheet" type="text/css" href="../css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../layer/skin/layer.css">
</head>
<body>
<div class="wrap animated fadeInRight pd-40">

    <h2 class="zh_title blod500">缓存服务配置工具</h2>
    <div class="row manage_btn">
        <div class="col-sm-12">
            <button class="blue" id="newzh">新增</button>
        </div>
    </div>

    <div class="row manage_tb">
        <table  cellpadding="0" cellspacing="0" id="demo-table">
        </table>
    </div>


</div>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<!-- 滚动条- -->
<script type="text/javascript" src="../js/bootstrap-table.js"></script>
<script type="text/javascript" src="../js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript" src="../js/Jquery.ETTool-1.0.js"></script>
<script type="text/javascript" src="../layer/layer.js"></script>

<script type="text/javascript">
    localStorage.setItem("arrgun","")
    function linkTo(x){
        var str = x.split(",")
        localStorage.setItem("appCode",str[0])
        localStorage.setItem("appName",str[1])
    }
//    新增
    $("#newzh").click(function(){
        localStorage.setItem("edit","")
        parent.layer.open({
            type: 2,
            skin: 'layui-layer-gray',
            title: ['新增应用','font-size:20px;text-align:center;color:#424f62;font-weight:bolder'],
            scrollbar:false,
            area: ['900px', '430px'],
            //offset: [top, '253px'],
            shift: 2 ,
            content: 'app.html',
            success:function(index){
                console.log(index)
            }
        })

    })
//    修改
    function edit(x){
        localStorage.setItem("appCode",arguments[0].split(",")[0])
        localStorage.setItem("arrgun",arguments[0])
        localStorage.setItem("edit","true")
        parent.layer.open({
            type: 2,
            skin: 'layui-layer-gray',
            title: ['修改应用','font-size:20px;text-align:center;color:#424f62;font-weight:bolder'],
            scrollbar:false,
            area: ['900px', '430px'],
            //offset: [top, '253px'],
            shift: 2 ,
            content: 'app.html'
        })
    }
//    删除
    function deleteX(x){
        $.ajax({
            url: 'http://10.238.119.7:8080/apps/' + x,
            async: false,//
            type: 'DELETE',//PUT DELETE POST
            dataType:"text",
            success: function (result) {
                layer.msg("删除成功")
                setTimeout(function(){
                    window.location.reload()
                },500)
            }
        })
    }
        $(function () {
            $.ajax({
                url: 'http://10.238.119.7:8080/apps',
                async: false,//
                type: 'GET',//PUT DELETE POST
                success: function (result) {
                    var data = $.ET.toObjectArr(result)
                    initTable(data)
                }, error: function () {
                    alert("网络出错啦")
                }
            })
        });

    function initTable(data){
        $('#demo-table').bootstrapTable({
            data:data,
            pagination: true, //启动分页
            pageSize: 10,  //每页显示的记录数
            pageNumber:1, //当前第几页
            columns: [
                {
                    field: '',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index+1;
                    },
                    sortable : true
                },
                {
                    field : 'appCode',
                    title : '应用编码',
                    align : 'center',
                    valign : 'middle',
                    sortable : true
                } ,{
                    field : 'appName',
                    title : '应用名称',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'crtUserName',
                    title : '创建人',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'crtDate',
                    title : '创建日期',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'mntUserName',
                    title : '最后维护人',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'mntDate',
                    title : '最后维护日期',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'des',
                    title : '描述',
                    align : 'center',
                    valign : 'middle'
                },{
                    field : 'crtUserId',
                    title : '资源',
                    align : 'center',
                    valign : 'middle',
                    formatter:function(value,row,index){
                        var e = '<a href="资源.html" target="_blank" mce_href="#" onclick="linkTo(\''+ row.appCode +','+row.appName+ '\')">查看</a> ';;
                        return e;
                    }

                },{
                    field : 'appCode',
                    title : '操作',
                    align : 'center',
                    valign : 'middle',
                    formatter:function(value,row,index){
                        var e = '<a href="#" mce_href="#" onclick="edit(\''+ row.appCode + ','+row.appCode+','+row.appName+ ','+row.crtUserId+','+row.crtUserName + ','+row.mntUserId+','+row.mntUserName+ ','+row.des+'\')">修改</a> ';
                        var d = '<a href="#" mce_href="#" onclick="deleteX(\''+ row.appCode + '\')">删除</a> ';
                        return e+d;
                    }
                }]
        });
    }


</script>

</body>
</html>

